var gulp  =  require('gulp'),
	less  =  require('gulp-less'),
	cleanCSS = require('gulp-clean-css'),
	rename = require('gulp-rename'),
	sourcemaps = require('gulp-sourcemaps'),
	browsersSync = require('browser-sync'),
	autoprefixer = require('gulp-autoprefixer');

gulp.task( 'serve' , function () {
	browsersSync.init( {
		server: {
			baseDir: './src/'
		},
		startPath: 'index.html'
	} )
} )

gulp.task( 'less' , function () {
	gulp.src( 'src/less/*.less' )
		.pipe( sourcemaps.init() )
		.pipe( less() )
		.pipe( autoprefixer( { browsers: [ 'last 2 versions' ] } ) )
		.pipe( gulp.dest( 'src/css' ) )
		.pipe( cleanCSS() )
		.pipe( rename( { suffix: '.min' } ) )
		.pipe( sourcemaps.write( './' ) )
		.pipe( gulp.dest( 'src/css' ) )
		.pipe( browsersSync.reload( { stream: true } ) )
});

gulp.task( 'watch' , function () {
	gulp.watch( 'src/less/*.less' , [ 'less' ] );
	gulp.watch( 'src/html/*.html' , browsersSync.reload() );
} );

gulp.task( 'default' , [ 'serve' , 'watch' ] );

















